package com.lzy.huijinjiazu.mvp.ui.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.flyco.tablayout.SlidingTabLayout;
import com.jess.arms.base.BaseFragment;
import com.jess.arms.di.component.AppComponent;
import com.lzy.huijinjiazu.R;
import com.lzy.huijinjiazu.di.component.DaggerMallCollectComponent;
import com.lzy.huijinjiazu.di.module.MallCollectModule;
import com.lzy.huijinjiazu.mvp.contract.MallCollectContract;
import com.lzy.huijinjiazu.mvp.presenter.MallCollectPresenter;
import com.lzy.huijinjiazu.mvp.ui.adapter.TabsAdapter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;


public class MallCollectFragment extends BaseFragment<MallCollectPresenter> implements MallCollectContract.View {


    @BindView(R.id.tabLayout)
    SlidingTabLayout mTabLayout;
    @BindView(R.id.viewPager)
    ViewPager mViewPager;

    public static MallCollectFragment newInstance() {
        MallCollectFragment fragment = new MallCollectFragment();
        return fragment;
    }

    @Override
    public void setupFragmentComponent(AppComponent appComponent) {
        DaggerMallCollectComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .mallCollectModule(new MallCollectModule(this))
                .build()
                .inject(this);
    }

    @Override
    public View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_mall_collect, container, false);
    }

    @Override
    public void initData(Bundle savedInstanceState) {
        mPresenter.initTabLayout();
    }

    @Override
    public void showTabLayout(String[] title, Fragment[] tabFragment) {
        mViewPager.setAdapter(new TabsAdapter(getChildFragmentManager(), tabFragment, title));
        mTabLayout.setViewPager(mViewPager);
        mTabLayout.setCurrentTab(0);
    }
}
